/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2019
 */

package net.dreamlu.db.po;


import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.format.annotation.DateTimeFormat;


import lombok.Data;
import lombok.extern.slf4j.Slf4j;
/**
 *
 * @author lambert.wang email:lambert.wang(a)crediteyes.com
 * @version 1.0
 * @since 1.0
 */
@Data
@Slf4j
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "t_sys_log")
public class SysLog implements Serializable {
	private static final long	serialVersionUID	= 5454155825314635342L;
	//alias
	public static final String TABLE_ALIAS = "SysLog";
	public static final String ALIAS_ID = "主键id";
	public static final String ALIAS_USERNAME = "登陆名";
	public static final String ALIAS_ROLE_NAME = "角色名";
	public static final String ALIAS_OPERATION = "操作";
	public static final String ALIAS_CLASS_METHOD = "类-方法";
	public static final String ALIAS_CONTENT = "内容";
	public static final String ALIAS_CLIENT_IP = "客户端ip";
	public static final String ALIAS_CREATE_TIME = "创建时间";
	
	public static final String PROP_ID = "id";
	public static final String PROP_USERNAME = "username";
	public static final String PROP_ROLE_NAME = "roleName";
	public static final String PROP_OPERATION = "operation";
	public static final String PROP_CLASS_METHOD = "classMethod";
	public static final String PROP_CONTENT = "content";
	public static final String PROP_CLIENT_IP = "clientIp";
	public static final String PROP_CREATE_TIME = "createTime";
	//columns START
    /**
     * 主键id       db_column: id 
     */ 	
	@Id 
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", unique = true, nullable = false, insertable = true, updatable = true, length = 10)
	private java.lang.Integer id;
    /**
     * 登陆名       db_column: username 
     */ 	
	@Column(name = "username", unique = false, nullable = true, insertable = true, updatable = true, length = 20)
	private java.lang.String username;
    /**
     * 角色名       db_column: role_name 
     */ 	
	@Column(name = "role_name", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	private java.lang.String roleName;
    /**
     * 操作       db_column: operation 
     */ 	
	@Column(name = "operation", unique = false, nullable = true, insertable = true, updatable = true, length = 64)
	private java.lang.String operation;
    /**
     * 类-方法       db_column: class_method 
     */ 	
	@Column(name = "class_method", unique = false, nullable = false, insertable = true, updatable = true, length = 100)
	private java.lang.String classMethod;
    /**
     * 内容       db_column: content 
     */ 	
	@Column(name = "content", unique = false, nullable = true, insertable = true, updatable = true, length = 2000)
	private java.lang.String content;
    /**
     * 客户端ip       db_column: client_ip 
     */ 	
	@Column(name = "client_ip", unique = false, nullable = false, insertable = true, updatable = true, length = 255)
	private java.lang.String clientIp;
    /**
     * 创建时间       db_column: create_time 
     */ 	
	@CreatedDate				
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") 
	@Column(name = "create_time", unique = false, nullable = false, insertable = true, updatable = true, length = 19)
	private java.time.LocalDateTime createTime;
	//columns END
	@Override
	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.JSON_STYLE)
			.append(PROP_ID,getId())
			.append(PROP_USERNAME,getUsername())
			.append(PROP_ROLE_NAME,getRoleName())
			.append(PROP_OPERATION,getOperation())
			.append(PROP_CLASS_METHOD,getClassMethod())
			.append(PROP_CONTENT,getContent())
			.append(PROP_CLIENT_IP,getClientIp())
			.append(PROP_CREATE_TIME,getCreateTime())
			.toString();
	}
	@Override
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof SysLog == false) return false;
		if(this == obj) return true;
		SysLog other = (SysLog)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
	
}
